package org.glorylight.hacks.social.model;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.glorylight.hacks.social.util.UUIDType;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

@Entity
@Table(name = "picture")
@TypeDefs({@TypeDef(name = "uuid", typeClass = UUIDType.class)})
@NamedQueries({
	@NamedQuery(name = "pictures-by-user", query = "from Picture a where a.userId = :userId"),
	@NamedQuery(name = "pictures-by-user-date", query = "from Picture a where a.userId = :userId " +
				"AND (a.dateCreated BETWEEN :startDate AND :endDate)"),
	@NamedQuery(name = "pictures-by-date", query = "from Picture a where a.dateCreated BETWEEN :startDate AND :endDate")
	})
public class Picture implements Serializable {
	
	private static final long serialVersionUID = -5168339546561957975L;
	
	@Id
	@Type(type = "uuid")
	@Column(length = 32)
	private UUID id;
	
	@Column(name = "userId")
	private String userId;
	
	@Column(name = "pic_path")
	private String picPath;
	
	@Column(name = "title")
	private String title;
	
	@Column(name = "description")
	private String description;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "date_created")
	private Date dateCreated;
		
	public Picture(UUID id, String picPath, String userId, String title, String description, Date createdDate) {
		this.picPath = picPath;
		this.title = title;
		this.description = description;
		this.dateCreated = createdDate;
		this.userId = userId;
		this.id = id;
	}

	public Picture(){
	}
	
	public String getPicPath() {
		return picPath;
	}

	public void setPicPath(String picPath) {
		this.picPath = picPath;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public UUID getId() {
		return id;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
	
}
